package com.saicyc.demo.application.impl;

import com.saicyc.demo.application.NewsApplication;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class NewsApplicationImpl implements NewsApplication {
    @Override
    public Boolean findUserReleationGood(Long id, Long userId) {
        return null;
    }

    @Override
    public Boolean upsertUserRelationGood(Long id, Long userId) {
        return null;
    }

    /*@Resource
    private LettuceConnectionFactory lettuceConnectionFactory;

    @Override
    public Boolean findUserReleationGood(Long id, Long userId) {
        Executors.newFixedThreadPool(int nThreads)
        LettuceReactiveRedisConnection redisConnection = lettuceConnectionFactory.getReactiveConnection();
        RedisStringCommands redisCommands = redisConnection.stringCommands();
        String s = redisCommands.get(id+"-"+userId);
        if(!"1".equals(s)){
            return Boolean.FALSE;
        }
        return Boolean.TRUE;
    }

    @Override
    public Boolean upsertUserRelationGood(Long id, Long userId) {
        try {
            String s = redisCommands.set(id + "-" + userId, "1", new SetArgs().nx().ex(10000L));
            if(!s.equals("ok")){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
            return Boolean.FALSE;
        }
        return Boolean.TRUE;
    }*/

}
